#coding=utf-8
#!/usr/bin/python





#     cd /d D:\python26 
#     python.exe D:\py\demo\updb.py

#       python.exe  .\dev_test\db_sqlite.py
   

"""


xlrd-0.6.1.win32.exe
xlrs读取Excel文件

"""

import os, sys, string
import re
try:
    import xlrd
except Exception, e:
    print e
    print __file__
    sys.exit()


xls_file =  u"D:/Program Files/Tencent/QQ/Users/909239005/FileRecv/手机.xls" 

#print file

xls = xlrd.open_workbook(xls_file)
#print xls.sheet_names()
#book_tab = xls.sheet_by_index(0)
book_tab = xls.sheet_by_name(u'Sheet1')
#行数
#print book_tab.nrows
for rownum in range(book_tab.nrows):
    #获取每行第一列 并转成字符传 
    tmp_str = str(book_tab.row_values(rownum)[0])
    str_a = None
    str_e = None
    
    #原型 re.match(pattern, string, flags)
    #匹配手机  1XXXXXXXXXX 
    ma = re.match(u".*?(1[\d]{10,10})", tmp_str)
    if ma:  
        #匹配 截取
        #str_po = ma.span()
        #ma_str = tmp_str[str_po[0]:str_po[1]]
        #所有
        #ma.group(0) 
        #第一组
        #ma.group(1)
        print ma.group(1)
        

    else:  
        print 'not match'  

#获取某一格
#cell_C4 = book_tab.cell(rowx=2,colx=1).value
#print cell_C4

    
